package test;

public class AgeExcetion extends Exception{
    public AgeExcetion(String message)
    {
        super(message);
    }
}
class Test1{
    public static void main(String[] args) throws AgeExcetion {
        inputAge(-5);
    }
    public static void inputAge(int age) throws AgeExcetion
    {
        if(age<0||age>120)
        {
            throw new AgeExcetion("年龄不合法");
        }
        else
        {
            System.out.println("年龄合法");
        }
    }
}
